package cs6238.common.message.command;

import java.nio.ByteBuffer;

import cs6238.common.DelegateEntry;
import cs6238.common.message.MessageId;

public class DelegateCommand extends Command {

	private DelegateEntry _entry;
	
	@Override
	public byte[] serialize() {
		byte[] entrySerial = _entry.serialize();
		ByteBuffer bb = ByteBuffer.allocate(4 + entrySerial.length);
		bb.putInt(MessageId.DELEGATE_COMMAND.ordinal());
		bb.put(entrySerial);
		return bb.array();
	}

	@Override
	public void deserialize(byte[] buffer) {
		ByteBuffer bb = ByteBuffer.wrap(buffer);
		bb.getInt();
		_entry = new DelegateEntry(bb);
	
	}
	
	
	public void setDelegateEntry(DelegateEntry entry){
		_entry = entry;
	}
	
	public DelegateEntry getDelegateEntry(){
		return _entry;
	}
}
